import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _dec2, _dec3, _dec4, _class, _class2;

/**
 * 个性化配置 详情页
 * @date: 2018-12-3


 */
import React from 'react';
import { connect } from 'dva'; // import {find, isEqual, isEmpty, omit} from 'lodash';

import { Bind } from 'lodash-decorators';
import { getCurrentOrganizationId } from 'utils/utils';
import notification from 'utils/notification';
import PageDesigner from "../../designer";
var PageDetail = (_dec = connect(function (_ref) {
  var uiPageOrg = _ref.uiPageOrg,
      loading = _ref.loading;
  return {
    uiPage: uiPageOrg,
    fetching: loading.effects['uiPageOrg/fetchPageDetail'],
    updating: loading.effects['uiPageOrg/updatePageDetail'],
    organizationId: getCurrentOrganizationId()
  };
}), _dec2 = Bind(), _dec3 = Bind(), _dec4 = Bind(), _dec(_class = (_class2 = /*#__PURE__*/function (_React$Component) {
  _inherits(PageDetail, _React$Component);

  var _super = _createSuper(PageDetail);

  function PageDetail() {
    _classCallCheck(this, PageDetail);

    return _super.apply(this, arguments);
  }

  _createClass(PageDetail, [{
    key: "render",
    value: function render() {
      return /*#__PURE__*/React.createElement(PageDesigner, Object.assign({}, this.props, {
        getPageDetail: this.getPageDetail,
        onSave: this.handleDesignerSave,
        bankPath: "/cpfm/ui/page-org/list"
      }));
    }
  }, {
    key: "handleDesignerSave",
    value: function handleDesignerSave(saveConfig) {
      var _this$props = this.props,
          dispatch = _this$props.dispatch,
          organizationId = _this$props.organizationId;
      return dispatch({
        type: 'uiPageOrg/detailUpdate',
        payload: {
          organizationId: organizationId,
          config: saveConfig
        }
      }).then(function (res) {
        if (res) {
          // 保存成功
          notification.success();
        }

        return res;
      });
    }
    /**
     *
     */

  }, {
    key: "getPageDetail",
    value: function getPageDetail() {
      var _this$props2 = this.props,
          dispatch = _this$props2.dispatch,
          organizationId = _this$props2.organizationId;
      var pageCode = this.getPageCode();
      return dispatch({
        type: 'uiPageOrg/fetchDetail',
        payload: {
          organizationId: organizationId,
          pageCode: pageCode
        }
      });
    }
  }, {
    key: "getPageCode",
    value: function getPageCode() {
      var pageCode = this.props.match.params.pageCode;
      return pageCode;
    }
  }]);

  return PageDetail;
}(React.Component), (_applyDecoratedDescriptor(_class2.prototype, "handleDesignerSave", [_dec2], Object.getOwnPropertyDescriptor(_class2.prototype, "handleDesignerSave"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "getPageDetail", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "getPageDetail"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "getPageCode", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "getPageCode"), _class2.prototype)), _class2)) || _class);
export { PageDetail as default };